CSE 16: Applied Discrete Mathematics
Instructor: Owen Arden
Winter 2023
… this joke is getting old, isn’t it?
Counting ends up being an important topic in discrete math, and is often not as simple as it seems.
There are 74 distinct characters in the base Super Smash Bros. Ultimate (if you count the Pokemon Trainer as one character). How many different 5 vs 5 tag team matches are there?
IMPORTANT: Players can’t choose the same character twice.
3.736688797550822e18!!!
Scenario:
The breakfast special includes a drink (Coffee or OJ), a main course (pancakes or eggs), and a side (bacon, sausage, hash browns).
How many different breakfasts selections are there?
So \(|\{\text{coffee, oj}\}|*|\{\text{pancake, eggs}\}|*|\{\text{bacon, sausage, eggs}\}| = 12\)
Are there \(|74|^{10}\) 5 vs 5 matches then?
\[|74|^{10}=4.923990397355877e18\]
hmm… what is different?
The product rule is used for independent choices.
For example, choosing OJ for breakfast didn’t affect which choices were available for mains or sides.
Choosing Smash characters is not independent: each player’s choice reduces the characters available for the next choice.
Suppose I told you that each player has \(P_5 = 1933051680\) choices of team lineups.
The choices each player makes are independent of each other. (We can both choose Pikachu)
So \(P_5 * P_5 = 3.736688797550822e18\) gives us the number.
For the number of breakfast selections and the number of matches (given \(P_5\)), we chose one element from each set.
What about when only one selection is made from multiple sets? For this, we use the sum rule.
What if we wanted to know the number of all tag team matches (both 3 vs 3 and 5 vs 5)?
If \(P_3\) is the number of choices each player has for 3-character lineups, then the number possible matches is: \[ P_3 * P_3 + P_5 * P_5 \]
In other words, the number of 3 vs 3 plus the number of 5 vs 5.
This is useful if we know how to count one set and can map every element to another set which might be harder to count.
Example: Counting tickets to know how many people are in a theater.
We can use other mappings to count sets in terms of other sets.
Example: A bounce house operator needs to make sure no more than 10 kids are in the bounce house at a time.
But seriously, how do we count the number of 5 vs 5 lineups?
We couldn’t use the product rule to calculate \(P_5\) since the choices were not independent, but we can use a generalization of the product rule as long as the number of choices at each step doesn’t depend on previous choices.
Are we there yet?
There are 74 characters (if you count the Pokemon trainer as one), So there are 74 choices for the first character, 73 for the second, and so on.
Does the number of choices depend on which characters were previously chosen?
No! And \(P_5 = 74*73*72*71*70 = 1933051680\)
Counting \(P_5\) is an example of a common application of the generalized product rule: for counting permutations.
Example: Pikachu, Kirby, Link is a 3-permutation of the set of Smash characters.
Example: \[P_5 = P(74,5) = \dfrac{74!}{(74-5)!} = 74*73*72*71*70\]
A bank PIN is a string of four digits, each digit 0-9. How many choices are there for a PIN if the last digit must be odd and all the digits must be different from each other?
Tricky! Strategy: count the digit with extra contraints separately.
How many ways to choose an odd digit in 0-9? 10/2 = 5.
That takes care of the last digit, but also reduces the available digits by 1.
For the remaining 3 digits, one is a choice from the 9 remaining digits, one is a choice from 8 digits (since two other digits have been chosen), and one is a choice from 7 digits.
We now have the 4 sets we need to choose our sequence from. Using the product rule, the number of possible PIN codes is \[9 \cdot 8 \cdot 7 \cdot 5\].
What if the order of the characters didn’t matter? Say we wanted to count the number of distinct 3-character teams.
In this case the sequences (Pikachu, Kirby, Link), (Kirby, Pikachu, Link) etc are counted only once.
The teams are now more like sets than sequences.
We already have an easy way to count r-permutations, but this would overcount r-subsets.
But! It turns out it overcounts by the same ratio for each subset.
Consider the number of permutations of the 3-subset {Pikachu, Kirby, Link}: \(P(3, 3) = 3!/(3 - 3)! = 3!\)
Combining the general product rule and the k-to-1 rule, we come up with a definition for the number of r-subsets in a set of size \(n\).
\(C(n,r)\) can also be written \({n \choose r}\) and pronounced “n choose r”
So the number of distinct 3-character teams?
\[S_3 = \dfrac{74!}{3!(74-3)!} = 64,824\]
Counting by complement counts the number of elements in a subset \(P \subseteq S\) by counting the elements not in \(P\). \[|P| = |S| - |\overline{P}|\]
How many ways to scramble Mississippi?
\[\text{M}\text{i}_1\text{s}_1\text{s}_2\text{i}_2\text{s}_3\text{s}_4\text{i}_3\text{p}_1\text{p}_2\text{i}_4 = \text{M}\text{i}_2\text{s}_2\text{s}_1\text{i}_1\text{s}_4\text{s}_3\text{i}_4\text{p}_2\text{p}_1\text{i}_3\]
We can generalize this approach for counting arbitrary permutations on a set \(S\) where \(a_1 \in S\) is repeated \(n_1\) times, \(a_2 \in S\) is repeated \(n_2\), etc.
To find the number of distinct sequences of length \(n\) of elements \(a_i\) from \(S\) where \(a_i\) is repeated \(n_i\) times and \(\sum_i^{n} n_i = n\):
\[{n \choose n_1} \cdot {n - n_1 \choose n_2} \cdot {n - n_1 - n_2 \choose n_3} \cdot {n - n_1 - n_2 ... - n_{k-1} \choose n_k}\] which simplifies to \(\dfrac{n!}{n_1!n_2!...n_k!}\)
Like a set, order does not matter. However, the number of each variety of element does matter.
For a set, \(\{b, a, n, a, n, a\} = \{b, a, n\}\). For a multiset, \(\{b, a, n, a, n, a\} \neq \{b, a, n\}\), but \(\{b, a, n, a, n, a\} = \{a, n, a, n, a, b\}\).
What are the varieties of the above multisets?
Lots of counting problems can be modeled as counting the number of ways to assign elements to numbered bins.
How to count the assignments depends on the distinguishability of the elements and any constraints on the assignments.
On the board:
3 indistinguishable balls, 5 bins
3 distinguishable balls, 5 bins
In general: \[{n \choose (n/m)} \cdot {n - (n/m) \choose (n/m)} \cdot {n - 2(n/m) \choose (n/m)} \cdots \cdot {2(n/m) \choose (n/m)} \cdot {(n/m) \choose (n/m)}\] which simplifies to \[\dfrac{n!}{(n/m)!(n/m)!\cdots(n/m)!} = \dfrac{n!}{((n/m)!)^m}\]
The number of ways to place \(n\) balls into \(m\) distinguishable bins:
No restrictions | \(\leq 1\) per bin | same # per bin | |
---|---|---|---|
\(~\) | \((m \geq 1 \text{ and } n \geq 1)\) | (\(m \geq n\)) | (m divides n) |
Indistinguishable balls | \[n + m -1 \choose m - 1\] | \[m \choose n\] | \[1\] |
Distinguishable balls | \[m^n\] | \[P(m,n)\] | \[\dfrac{n!}{((n/m)!)^m}\] |
The Burger King I drive by on the way to campus claims there are 221,184 ways to order a Whopper.
For 1% extra credit on your (overall) homework grade,